package ch.usi.inf.pf2.analyzer;
import junit.framework.TestCase;
import ch.usi.inf.pf2.analyzer.Token;
import ch.usi.inf.pf2.analyzer.TokenRecognizer;
import ch.usi.inf.pf2.analyzer.TokenType;

/**
 * 
 * @author Thomas Mantegazzi, Yotam Sharon
 * @date 22 april 2010
 *
 */


public class TestTokenRecognizer extends TestCase {
	private TokenRecognizer tr;
	
	
	protected void setUp() {
		tr = new TokenRecognizer(TokenType.PLUS,"\\+");
		tr.setText("ljasd+kjabsd");
	}
	
	public void testPositiveFind() {
		assertEquals(true,tr.find(5));
	}
	
	public void testNegativeFind() {
		assertEquals(false,tr.find(2));
	}
	
	public void testGetToken() {
		tr.find(5);
		Token token = tr.getToken();
		assertEquals("+",token.getText());
		assertEquals(5,token.getStartPosition());
		assertEquals(TokenType.PLUS, token.getType());
	}
	
	
	
	
	
}
